package src;

import java.util.Scanner;
public class StudentManager {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Student[] students = new Student[3];
        System.out.println("--- 请输入3名学生的信息 ---");

        for (int i = 0; i < students.length; i++) {
            System.out.println("请输入第 " + (i + 1) + " 名学生的信息:");
            System.out.print("学号: ");
            String id = scanner.nextLine();

            System.out.print("姓名: ");
            String name = scanner.nextLine();

            System.out.print("年龄: ");
            int age = scanner.nextInt();
            scanner.nextLine(); // 消费掉换行符
            students[i]=new Student(id,name,age);
        }

        System.out.println("\n--- 所有学生信息如下 ---");
        for(Student student:students){
            System.out.println(student);
        }


        System.out.println("\n--- equals 和 hashCode 验证 ---");
        Student s1 = new Student("2024001", "张三", 20);
        Student s2 = new Student("2024001", "张小三", 21); // 学号相同，但其他信息不同
        System.out.println("s1.equals(s2) 的结果应该是 true: " + s1.equals(s2));
        System.out.println("s1.hashCode() == s2.hashCode() 的结果应该是 true: " + (s1.hashCode() == s2.hashCode()));
    }
}

